<?php 


namespace app\admin\controller;

use think\Controller;
use think\Db;
use think\Request;
use app\admin\controller\Admin;

/**
* 
*/
class manpower extends Admin
{
    /**
     * [index 加载首页]
     */
    public function index()
    {
        $manpower = db('_employee_information')
            ->select();
        //var_dump($manpower);die;
        return view('admin@manpower/index',[
            'manpower' => $manpower
        ]);
    }


    /**
     * [addman 加载添加人力页面]
     */
    public function addman()
    {
        
        return view('admin@manpower/addman');
    }


    /**
     * [doaddman 加载添加人力页面]
     */
    public function doaddman()
    {
        $res = input('param.');
        //var_dump($res);die;
        //var_dump($res);die;
        $result = db('_employee_information')
                  ->insert($res);

        if ($result > 0) {
            return $this->success('添加成功!', url('admin/manpower/index'));
        } else {
            return $this->error('添加失败!');
        }
    }



    /**
     * [dodelman 加载添加人力页面]
     */
    public function dodelman()
    {
        $p = input('param.');
        //var_dump($p);exit;

        //把用户角色表中相关的也删除
        if(db('_employee_information')->where('id',$p['id'])->delete()){
            $this->success("删除成功！",url('admin/manpower/index'));
        }else{
            $this->error("删除失败");
        }
    }






    /**
     * [contract 加载劳动合同页面]
     */
    public function contract()
    {
        $manpower = db('_lab_contract')
            ->select();
        //var_dump($manpower);die;
        return view('admin@manpower/contract',[
            'manpower' => $manpower
        ]);
    }




    /**
     * [addcontract 加载添加劳动合同页面]
     */
    public function addcontract()
    {
        //var_dump($manpower);die;
        return view('admin@manpower/addcontract');
    }


    /**
     * [doaddcontract 执行添加劳动合同页面]
     */
    public function doaddcontract()
    {
        $res = input('post.');
        //var_dump($res);die;
        //var_dump($res);die;
        $result = db('_lab_contract')
                  ->insert($res);
        if ($result > 0) {
            return $this->success('添加成功!', url('admin/manpower/contract'));
        } else {
            return $this->error('添加失败!');
        }
    }

































    /**
     * [bulletin 加载招聘公告表]
     */
    public function bulletin()
    {
        $manpower = db('_recruitment_bulletin')
            ->select();
        //var_dump($manpower);die;
        return view('admin@manpower/bulletin',[
            'manpower' => $manpower
        ]);
    }


    /**
     * [addbulletin 加载添加招聘公告页面]
     */
    public function addbulletin()
    {

        //var_dump($manpower);die;
        return view('admin@manpower/addbulletin');
    }


    /**
     * [doaddbulletin 执行添加招聘公告]
     */
    public function doaddbulletin()
    {
        $res = input('param.');
        //var_dump($res);die;
        //var_dump($res);die;
        $result = db('_recruitment_bulletin')
                  ->insert($res);

        if ($result > 0) {
            return $this->success('添加成功!', url('admin/manpower/bulletin'));
        } else {
            return $this->error('添加失败!');
        }

    }



    
    /**
     * [editbulletin 加载编辑招聘公告]
     */
    public function editbulletin()
    {
        $p = input('param.');
        //var_dump($p);die;
        $id = $p['id'];
        $res = db('_recruitment_bulletin')->field(['id','recruitment_unit','recruitment_position','recruitment_num','job_description','orporate_welfare','salary','status'])->find($id);
        //var_dump($res);die;
        return view('admin@manpower/editbulletin',[
            'res' => $res
        ]);

    }


     /**
     * [doeditbulletin 执行编辑招聘公告]
     */
    public function doeditbulletin()
    {
        $p = input('param.');
        //var_dump($p);die;
        $id = $p['id'];

        $result = db('_recruitment_bulletin')->where('id='.$id)->update($p);
        //var_dump($res);die;
        if ($result > 0) {
            return $this->success('编辑成功!', url('admin/manpower/bulletin'));
        } else {
            return $this->error('编辑失败!');
        }

    }






    /**
     * [dodelbulletin 执行删除招聘公告]
     */
    public function dodelbulletin()
    {
         $p = input('param.');
        //var_dump($p);exit;

        //把用户角色表中相关的也删除
        if(db('_recruitment_bulletin')->where('id',$p['id'])->delete()){
            $this->success("删除成功！",url('admin/manpower/bulletin'));
        }else{
            $this->error("删除失败");
        }

    }































}

 ?>